<template>
	<view class="page">
		<view class="form-content">
			<u-form :model="formData" ref="uForm" class="uForm" label-position="left">
				<u-form-item prop="nickName" label="昵称" label-width="auto" v-if="formData.roleName!='信贷管家'">
					<u-input v-model="formData.nickName" placeholder="请输入昵称" input-align="right" />
				</u-form-item>
				<u-form-item prop="account" label="账号" label-width="auto">
					<u-input v-model="formData.account" disabled placeholder="请输入企业名称" input-align="right" />
				</u-form-item>
				<!-- <u-form-item prop="realName" label="姓名" label-width="auto">
					<u-input v-model="formData.realName" placeholder="请输入姓名" input-align="right" />
				</u-form-item>
				<u-form-item prop="mobilePhone" label="手机号" label-width="auto">
					<u-input v-model="formData.mobilePhone" placeholder="请输入手机号" maxlength="11" type="number"
						input-align="right" />
				</u-form-item> -->
			</u-form>
		</view>
		<view class="save-bottom">
			<view class="fixed-btn save-padding">
				<u-button type="primary" :disabled="btnDisabled" shape="circle" @click="onSubmit">确定</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/common/js/config.js';
	const apiKey = uni.getStorageSync('apiKey') || 'api';
	const baseUrlObj = config.Global.baseUrl;
	const baseUrl = config.Global.baseUrl[apiKey].apiUrl;
	export default {
		name: 'userInfo',
		data() {
			return {
				formData: {},
				btnDisabled: false
			}
		},
		onLoad(options) {
			try {
				const userProvider = uni.getStorageSync(config.Global.cache + '_UserProvider');;

				if (userProvider) {
					this.$helper.ajax({
						url: "/api/Permission/Users/Current/BaseInfo",
						method: "GET",
						contentType: "application/json",
						success: res => {
							this.formData = res.data.data
							this.formData.birthday = 0
						}
					});

				}
			} catch (e) {}
		},
		methods: {
			/* 表单提交 */
			onSubmit() {
				this.$helper.ajax({
					url: `/api/Permission/Users/Current/BaseInfo`,
					method: "PUT",
					contentType: "application/json",
					data: this.formData,
					success: res => {
						this.$helper.msg('保存成功', 'success');
						uni.removeStorage({
							key: config.Global.cache + '_UserProvider',
						});
						uni.navigateBack();
					}
				});
			},
		}
	}
</script>

<style>

</style>